//
//  AppDelegate.m
//  王宇先_02_TomCat
//
//  Created by wyx on 16/3/10.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "MyButton.h"

@interface AppDelegate ()

@end

@implementation AppDelegate
-(void)dealloc{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    ViewController *vc = [[ViewController alloc] init];
    self.window.rootViewController = vc;
    [_window release];
    [vc release];
    /** 设置背景图 */
    UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"angry_0.jpg"]];
    backgroundImage.frame = CGRectMake(0, 0, 414, 736);
    [self.window addSubview:backgroundImage];
    [backgroundImage release];
    /** 添加不可见按钮 */
    //生气
    MyButton *buttonOfAngry = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfAngry.frame = CGRectMake(280, 610, 50, 50);
    //buttonOfAngry.backgroundColor = [UIColor yellowColor];
    [self.window addSubview:buttonOfAngry];
    [buttonOfAngry addTarget:self action:@selector(handleOfAngry:) forControlEvents:UIControlEventTouchUpInside];
    //你看的左脚
    MyButton *buttonOfLeft = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfLeft.frame = CGRectMake(215, 660, 50, 50);
    //buttonOfLeft.backgroundColor = [UIColor yellowColor];
    [self.window addSubview:buttonOfLeft];
    [buttonOfLeft addTarget:self action:@selector(handleOfLeft:) forControlEvents:UIControlEventTouchUpInside];
    //右脚
    MyButton *buttonOfRight = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfRight.frame = CGRectMake(150, 660, 50, 50);
    //buttonOfRight.backgroundColor = [UIColor yellowColor];
    [self.window addSubview:buttonOfRight];
    [buttonOfRight addTarget:self action:@selector(handleOfRight:) forControlEvents:UIControlEventTouchUpInside];
    //打头
    MyButton *buttonOfHead = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfHead.frame = CGRectMake(160, 110, 100, 100);
    //buttonOfHead.backgroundColor = [UIColor yellowColor];
    [self.window addSubview:buttonOfHead];
    [buttonOfHead addTarget:self action:@selector(handleOfHead:) forControlEvents:UIControlEventTouchUpInside];
    //胃
    MyButton *buttonOfStomach = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfStomach.frame = CGRectMake(155, 525, 100, 100);
    //buttonOfStomach.backgroundColor = [UIColor yellowColor];
    [self.window addSubview:buttonOfStomach];
    [buttonOfStomach addTarget:self action:@selector(handleOfStomach:) forControlEvents:UIControlEventTouchUpInside];
    /** 添加可见按钮 */
    //大锣
    MyButton *buttonOfCymbal = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfCymbal.frame = CGRectMake(30, 410, 60, 60);
    //buttonOfCymbal.backgroundColor = [UIColor yellowColor];
    [buttonOfCymbal setBackgroundImage:[UIImage imageNamed:@"cymbal.png"] forState:UIControlStateNormal];
    [self.window addSubview:buttonOfCymbal];
    [buttonOfCymbal addTarget:self action:@selector(handleOfCymbal:) forControlEvents:UIControlEventTouchUpInside];
    //喝水
    MyButton *buttonOfDrink = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfDrink.frame = CGRectMake(30, 485, 60, 60);
    //buttonOfCymbal.backgroundColor = [UIColor yellowColor];
    [buttonOfDrink setBackgroundImage:[UIImage imageNamed:@"drink.png"] forState:UIControlStateNormal];
    [self.window addSubview:buttonOfDrink];
    [buttonOfDrink addTarget:self action:@selector(handleOfDrink:) forControlEvents:UIControlEventTouchUpInside];
    //吃
    MyButton *buttonOfEat = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfEat.frame = CGRectMake(30, 560, 60, 60);
    //buttonOfCymbal.backgroundColor = [UIColor yellowColor];
    [buttonOfEat setBackgroundImage:[UIImage imageNamed:@"eat.png"] forState:UIControlStateNormal];
    [self.window addSubview:buttonOfEat];
    [buttonOfEat addTarget:self action:@selector(handleOfEat:) forControlEvents:UIControlEventTouchUpInside];
    //馅饼
    MyButton *buttonOfPie = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfPie.frame = CGRectMake(320, 485, 60, 60);
    //buttonOfCymbal.backgroundColor = [UIColor yellowColor];
    [buttonOfPie setBackgroundImage:[UIImage imageNamed:@"pie.png"] forState:UIControlStateNormal];
    [self.window addSubview:buttonOfPie];
    [buttonOfPie addTarget:self action:@selector(handleOfPie:) forControlEvents:UIControlEventTouchUpInside];
    //fart
    MyButton *buttonOfFart = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfFart.frame = CGRectMake(320, 410, 60, 60);
    //buttonOfCymbal.backgroundColor = [UIColor yellowColor];
    [buttonOfFart setBackgroundImage:[UIImage imageNamed:@"fart.png"] forState:UIControlStateNormal];
    [self.window addSubview:buttonOfFart];
    [buttonOfFart addTarget:self action:@selector(handleOfFart:) forControlEvents:UIControlEventTouchUpInside];
    //抓痕
    MyButton *buttonOfScratch = [MyButton buttonWithType:UIButtonTypeSystem];
    buttonOfScratch.frame = CGRectMake(320, 560, 60, 60);
    //buttonOfCymbal.backgroundColor = [UIColor yellowColor];
    [buttonOfScratch setBackgroundImage:[UIImage imageNamed:@"scratch.png"] forState:UIControlStateNormal];
    [self.window addSubview:buttonOfScratch];
    [buttonOfScratch addTarget:self action:@selector(handleOfScratch:) forControlEvents:UIControlEventTouchUpInside];
    return YES;
}
-(void)handleOfAngry:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfAngry = [[NSMutableArray alloc] init];
    for (int i = 0; i < 26; i++) {
        NSString *name = [NSString stringWithFormat:@"angry_%d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfAngry addObject:image];
    }
    //生气动画
    UIImageView *imageOfAngry = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfAngry.animationImages = arrayOfAngry;
    imageOfAngry.animationDuration = 1.5;
    imageOfAngry.animationRepeatCount = 1;
    [imageOfAngry startAnimating];
    [self.window addSubview:imageOfAngry];
    [imageOfAngry release];
}
-(void)handleOfLeft:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfLeft = [[NSMutableArray alloc] init];
    for (int i = 0; i < 30; i++) {
        NSString *name = [NSString stringWithFormat:@"footLeft_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfLeft addObject:image];
    }
    //生气动画
    UIImageView *imageOfLeft = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfLeft.animationImages = arrayOfLeft;
    imageOfLeft.animationDuration = 3;
    imageOfLeft.animationRepeatCount = 1;
    [imageOfLeft startAnimating];
    [self.window addSubview:imageOfLeft];
    [imageOfLeft release];
}
-(void)handleOfRight:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfRight = [[NSMutableArray alloc] init];
    for (int i = 0; i < 30; i++) {
        NSString *name = [NSString stringWithFormat:@"footRight_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfRight addObject:image];
    }
    //生气动画
    UIImageView *imageOfRight = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfRight.animationImages = arrayOfRight;
    imageOfRight.animationDuration = 3;
    imageOfRight.animationRepeatCount = 1;
    [imageOfRight startAnimating];
    [self.window addSubview:imageOfRight];
    [imageOfRight release];
}
-(void)handleOfHead:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfHead = [[NSMutableArray alloc] init];
    for (int i = 0; i < 81; i++) {
        NSString *name = [NSString stringWithFormat:@"knockout_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfHead addObject:image];
    }
    //生气动画
    UIImageView *imageOfHead = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfHead.animationImages = arrayOfHead;
    imageOfHead.animationDuration = 8;
    imageOfHead.animationRepeatCount = 1;
    [imageOfHead startAnimating];
    [self.window addSubview:imageOfHead];
    [imageOfHead release];
}
-(void)handleOfStomach:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfStomach = [[NSMutableArray alloc] init];
    for (int i = 0; i < 34; i++) {
        NSString *name = [NSString stringWithFormat:@"stomach_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfStomach addObject:image];
    }
    //生气动画
    UIImageView *imageOfStomach = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfStomach.animationImages = arrayOfStomach;
    imageOfStomach.animationDuration = 3.4;
    imageOfStomach.animationRepeatCount = 1;
    [imageOfStomach startAnimating];
    [self.window addSubview:imageOfStomach];
    [imageOfStomach release];
}

-(void)handleOfCymbal:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfCymbal = [[NSMutableArray alloc] init];
    for (int i = 0; i < 13; i++) {
        NSString *name = [NSString stringWithFormat:@"cymbal_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfCymbal addObject:image];
    }
    //大锣动画
    UIImageView *imageOfCymbal = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfCymbal.animationImages = arrayOfCymbal;
    imageOfCymbal.animationDuration = 1.5;
    imageOfCymbal.animationRepeatCount = 1;
    [imageOfCymbal startAnimating];
    [self.window addSubview:imageOfCymbal];
    [imageOfCymbal release];
}
-(void)handleOfDrink:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfDrink = [[NSMutableArray alloc] init];
    for (int i = 0; i < 81; i++) {
        NSString *name = [NSString stringWithFormat:@"drink_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfDrink addObject:image];
    }
    //生气动画
    UIImageView *imageOfDrink = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfDrink.animationImages = arrayOfDrink;
    imageOfDrink.animationDuration = 8;
    imageOfDrink.animationRepeatCount = 1;
    [imageOfDrink startAnimating];
    [self.window addSubview:imageOfDrink];
    [imageOfDrink release];
}
-(void)handleOfEat:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfEat = [[NSMutableArray alloc] init];
    for (int i = 0; i < 40; i++) {
        NSString *name = [NSString stringWithFormat:@"eat_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfEat addObject:image];
    }
    //吃动画
    UIImageView *imageOfEat = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfEat.animationImages = arrayOfEat;
    imageOfEat.animationDuration = 4;
    imageOfEat.animationRepeatCount = 1;
    [imageOfEat startAnimating];
    [self.window addSubview:imageOfEat];
    [imageOfEat release];
}
-(void)handleOfFart:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfFart = [[NSMutableArray alloc] init];
    for (int i = 0; i < 28; i++) {
        NSString *name = [NSString stringWithFormat:@"fart_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfFart addObject:image];
    }
    //屁动画
    UIImageView *imageOfFart = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfFart.animationImages = arrayOfFart;
    imageOfFart.animationDuration = 4;
    imageOfFart.animationRepeatCount = 1;
    [imageOfFart startAnimating];
    [self.window addSubview:imageOfFart];
    [imageOfFart release];
}
-(void)handleOfPie:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfPie = [[NSMutableArray alloc] init];
    for (int i = 0; i < 24; i++) {
        NSString *name = [NSString stringWithFormat:@"pie_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfPie addObject:image];
    }
    //大饼动画
    UIImageView *imageOfPie = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfPie.animationImages = arrayOfPie;
    imageOfPie.animationDuration = 3;
    imageOfPie.animationRepeatCount = 1;
    [imageOfPie startAnimating];
    [self.window addSubview:imageOfPie];
    [imageOfPie release];
}
-(void)handleOfScratch:(UIButton *)button{
    //创建数组存照片
    NSMutableArray *arrayOfScratch = [[NSMutableArray alloc] init];
    for (int i = 0; i < 55; i++) {
        NSString *name = [NSString stringWithFormat:@"scratch_%02d.jpg",i];
        UIImage *image = [UIImage imageNamed:name];
        [arrayOfScratch addObject:image];
    }
    //抓屏幕动画
    UIImageView *imageOfScratch = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    imageOfScratch.animationImages = arrayOfScratch;
    imageOfScratch.animationDuration = 5;
    imageOfScratch.animationRepeatCount = 1;
    [imageOfScratch startAnimating];
    [self.window addSubview:imageOfScratch];
    [imageOfScratch release];
}





- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
